package cn.ha.toy.web;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;

@Controller
@RequestMapping("telephones")
@SessionAttributes(value={"name","degree"},types={Double.class})
public class AttributeController {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@ModelAttribute("clazzName")
	public String setModel() {
		return this.getClass().getName();
	}
	
	@ModelAttribute
	public void setModel1(Model model){
		model.addAttribute("movie", "who");
	}
	
	@ModelAttribute()
	public String setModel2(){
		return "actor";
	}
	
	@RequestMapping(method=RequestMethod.GET)
	public String list(Model model){
		Map m = model.asMap();
		System.out.println("clazzName: "+m.get("clazzName"));
		System.out.println("movie: "+m.get("movie"));
		System.out.println("string: "+m.get("string"));
		return "redirect:300";
	}
	
//	@RequestMapping("")
}
